package com.ysstech.etfmanage.controller;


import java.util.HashMap;
import java.util.Map;

import com.ysstech.common.annotation.YssLog;
import com.ysstech.common.annotation.YssPermissions;
import com.ysstech.common.controller.BaseController;
import com.ysstech.common.util.resultutil.RestResult;
import com.ysstech.common.util.resultutil.ResultGenerator;
import com.ysstech.etfmanage.entity.DealDetaild;
import com.ysstech.etfmanage.service.DealDetaildService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.ResponseBody;

/**
 * <p>
 *  ETF成交明细前端控制器
 * </p>
 *
 * @author lishuangliang
 * @since 2021-02-25
 */
@Controller
@Slf4j
@Api(tags = "ETF成交明细api")
@RequestMapping("/dealDetaild")
public class DealDetaildController extends BaseController {
    @Autowired
    private DealDetaildService dealDetaildService;

    @YssPermissions(value = {"etfmanage:dealDetaild"})
    @ApiOperation(value = "跳转ETF成交明细管理页面")
    @YssLog(module = "ETF成交明细管理", remark = "跳转ETF成交明细管理页面")
    @RequestMapping(value = "/page")
    public String page() throws Exception {
        return "etfmanage/dealDetaild";
    }

    /**
     * 获取初始化页面下拉选项的值
     *
     * @return RestResult
     */
    @YssPermissions(value = {"etfmanage:dealDetaild"})
    @ApiOperation(value = "获取ETF成交明细页面机构的状态的值")
    @YssLog(module = "ETF成交明细管理", remark = "获取ETF成交明细面机构的状态的值")
    @PostMapping(value = "/init")
    @ResponseBody
    public RestResult init() throws Exception {
        Map<String, Object> map = new HashMap<>();

        return ResultGenerator.getSuccessResult("加载ETF字典信息成功！", map);
    }

    /**
     * 查询ETF成交明细列表信息
     *
     * @return
     */
    @YssPermissions(value = {"etfmanage:dealDetaild"})
    @ApiOperation(value = "获取ETF成交明细数据")
    @YssLog(module = "ETF成交明细管理", remark = "获取ETF成交明细数据")
    @PostMapping(value = "/listInfo")
    @ResponseBody
    public RestResult queryAccount(DealDetaild dealDetaild, String page, String rows) throws Exception {
        return ResultGenerator.getSuccessResult("获取ETF成交明细数据成功",
                dealDetaildService.queryAllEtfDealDetaild(dealDetaild, this.getPage(page, rows)));
    }
}
